<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>set_spec_from_line_number (Spec::Runner::OptionParser)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File vendor\plugins\rspec/lib/spec/runner/option_parser.rb, line 202</span>
      <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_spec_from_line_number</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">err</span>)
        <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">examples</span>.<span class="ruby-identifier">empty?</span>
          <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
            <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@file_factory</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>])
              <span class="ruby-identifier">source</span> = <span class="ruby-ivar">@file_factory</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>])
              <span class="ruby-identifier">example</span> = <span class="ruby-ivar">@spec_parser</span>.<span class="ruby-identifier">spec_name_for</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">line_number</span>)
              <span class="ruby-identifier">options</span>.<span class="ruby-identifier">parse_example</span>(<span class="ruby-identifier">example</span>)
            <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@file_factory</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>])
              <span class="ruby-identifier">err</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;You must specify one file, not a directory when using the --line option&quot;</span>
              <span class="ruby-identifier">exit</span>(<span class="ruby-value">1</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">err</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">$stderr</span>
            <span class="ruby-keyword kw">else</span>
              <span class="ruby-identifier">err</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{args[0]} does not exist&quot;</span>
              <span class="ruby-identifier">exit</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">err</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">$stderr</span>
            <span class="ruby-keyword kw">end</span>
          <span class="ruby-keyword kw">else</span>
            <span class="ruby-identifier">err</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Only one file can be specified when using the --line option: #{args.inspect}&quot;</span>
            <span class="ruby-identifier">exit</span>(<span class="ruby-value">3</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">err</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">$stderr</span>
          <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">else</span>
          <span class="ruby-identifier">err</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;You cannot use both --line and --example&quot;</span>
          <span class="ruby-identifier">exit</span>(<span class="ruby-value">4</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">err</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">$stderr</span>
        <span class="ruby-keyword kw">end</span>
      <span class="ruby-keyword kw">end</span></pre>
</body>
</html>